﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using DataAccess_Layer;
using System.Data;

namespace Business_Layer
{
    public static class Order_BUS
    {
        public static OrderDTO get(int id)
        {
            return Order_DAC.get(id);
        }

        /*
-- Return 1 : OK
-- Return 0 : The order has been delivered.
-- Return -1: The order has been out of date (>30 days).
-- Return -2: The order does not belong to the center
         */
        public static int delivery(long orderID, long centerID)
        {
            return Order_DAC.delivery(orderID, centerID);
        }

        public static DataTable getOrderProdDetail(long orderID)
        {
            return OrderProductDetail_DAC.get(orderID).ToDataTable<OrderProductDetailDTO>();
        }

        public static DataTable getOrderBonusDetail(int orderID)
        {
            return OrderBonusDetail_DAC.get(orderID).ToDataTable<OrderBonusDetailDTO>();
        }

        public static CustomerDTO getCustomerByOrderID(OrderDTO order)
        {
            foreach (CustomerDTO cus in Customer_BUS.getAllCustomer())
            {
                if (cus.ID == order.CustomerID)
                {
                    return cus;
                }
            }

            return null;
        }
    }
}
